The Movie Toolbox handles the details of displaying compressed image sequences that are stored in QuickTime movies. (For details, see the chapter "Movie Toolbox" in this book.) However, if you want to work with sequences in your application, the Image Compression Manager provides tools for decompressing image sequences. As with still-image compression, decompressing sequences requires additional effort on the part of your application. In addition, there are some processing considerations that are particular to sequence decompression. This section describes the steps necessary to decompress an image sequence. Then it discusses several points you should consider before decompressing a sequence.
When decompressing an image sequence, your application must first determine where to display the decompressed sequence. Your application must specify the destination graphics port to the Image Compression Manager. In addition, you may indicate that only a portion of the source image is to be displayed. You describe the desired portion of the image by specifying a rectangle in the coordinate system of the source image. You can determine the size of the source image by examining the image description structure associated with the image (see "The Image Description Structure" for more information about image description structures).
Your application may also specify that the image is to be mapped into the destination graphics port. The DecompressSequenceBegin function (described on DecompressSequenceBegin ) allows your application to specify a mapping matrix for the operation.
Your application can invoke additional effects by specifying a mask region or blend matte for the image. Mask regions and mattes control which pixels in the source image are drawn to the destination. Mask regions must be defined in the destination coordinate system. During decompression the Image Compression Manager displays only those pixels in the source image that correspond to bits in the mask that are set to 1. Mattes contain several bits per pixel and are defined in the coordinate system of the source image. Mattes provide a mechanism for blending pixels from source images.
Your application signals its intention to decompress an image sequence by issuing the Image Compression Manager's DecompressSequenceBegin function (see DecompressSequenceBegin for more information about this function). At this time your application specifies many of the parameters that govern the sequence-decompression operation. The Image Compression Manager, in turn, allocates system resources that are necessary for the operation.
Once you have started the sequence, you then decompress each image in the sequence. Call the DecompressSequenceFrame function to decompress the image (described on DecompressSequenceFrame ). It may be necessary or desirable for your application to change one or more of the decompression parameters while processing a sequence. The Image Compression Manager provides several functions that allow your application to modify such parameters as the accuracy, the transformation matrix, or the data-loading function. See "Changing Sequence-Decompression Parameters," for more information about these functions.
The Image Compression Manager manages the decompression operation and invokes the appropriate compressor component. The manager returns the decompressed image to the location specified by your application and applies any effects you may have specified.
After the entire sequence is decompressed, you end the process by calling the CDSequenceEnd function (described on CDSequenceEnd ).
Your application can, of course, decompress individual images from a sequence. When doing so, you must be careful to select only those frames that do not depend on other frames. That is, do not decompress frames from a sequence that has been temporally compressed unless you first decompress all the frames in sequence starting from the preceding key frame (see "Defining Key Frame Rates" for more information on key frames in image sequences). In general, you should decompress images from sequences as sequences, rather than as individual frames.
There are two special buffers associated with decompressing an image sequence: a screen buffer and an image buffer. The Image Compression Manager uses the screen buffer to reduce tearing artifacts that result when an image cannot be decompressed to the screen quickly enough. Tearing manifests itself when your eye sees parts of consecutive images simultaneously. Screen buffers should be the same size and pixel depth as the destination. This provides the fastest screen update speed. The compressor decompresses the image to the screen buffer, performing the time-consuming tasks associated with decompression. When the image is fully decompressed, the compressor quickly copies the image to the screen. Few sequences require the use of a screen buffer. You must determine whether it is appropriate to your application.
The Image Compression Manager uses image buffers when decompressing sequences that have been temporally compressed and therefore contain key frames. Image buffers are especially useful when you want to skip to random frames within a sequence. Random frame access in temporally compressed sequences forces the compressor to decompress all the frames between the nearest preceding key frame and the desired frame. Reconstructing the frame in this manner on the screen can result in jerky sequence display. As an alternative, the compressor can reconstruct the frame in the offscreen image buffer and then copy it to the screen when appropriate. Image buffers are allocated at an appropriate depth and size for the decompressor.
Your application can control the use of the image buffer by the compressor component. For example, you can force the compressor to draw images only to the image buffer, not to the screen. In this manner you can use the image buffer to build up sequences without making the process visible. You can also control when the compressor uses the image buffer. You may need to do this when your program is decompressing directly to the screen and suddenly is prevented from doing so (for example, when your window becomes hidden).